package org.nanotek.tika.tests.index;

import java.util.List;

import org.nanotek.cms.domain.lucene.ScoreDocument;
import org.nanotek.lucene.index.search.IndexSearchService;
import org.nanotek.lucene.query.QueryResult;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class IndexSearchServiceText {

	public IndexSearchServiceText() {
	}

	/**
	 * @param args
	 * @throws Exception 
	 */
	public static void main(String[] args) throws Exception {
		ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(new String[]{"base-index-config/index-service-context.xml"});
		IndexSearchService service = (IndexSearchService) ctx.getBean("indexSearchService");
		QueryResult results = service.search("package");
		System.out.println("Query : - " + "package");
		System.out.println("Result Size : " + results.getDocuments().size());
		List<ScoreDocument> scoreDocuments = results.getDocuments();
		for (ScoreDocument document : scoreDocuments){ 
			String title = document.getDocument().get("file_location"); 
			System.out.println(title);
		}
		System.out.println(service.getClass().getName());
	}

}
